package com.imooc;

import com.imooc.controller.WelcomeController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.*;
import org.springframework.core.io.*;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

/**
 * <h1>ApplicationContext常用容器</h1>
 *  {@link FileSystemXmlApplicationContext}  从文件系统加载配置
 *  {@link ClassPathXmlApplicationContext}  从classpath加载配置
 *  {@link XmlWebApplicationContext}  用于web应用程序的容器
 *  {@link AnnotationConfigServletWebServerApplicationContext}
 *  {@link AnnotationConfigApplicationContext}
 *
 *  {@link AbstractApplicationContext#refresh()} 大致功能
 *  		1. 容器初始化,配置解析
 *  		2. {@link BeanFactoryPostProcessor} 和{@link BeanPostProcessor}	的注册和激活
 *  		3. 国际化配置
 *  		4. ...
 *
 *  {@link Resource}  处理资源文件
 *  	{@link EncodedResource} :处理编码
 *  			{@link AbstractResource} --> {@link FileSystemResource}
 *  			{@link ResourceLoader}  --> {@link DefaultResourceLoader}
 *  		{@link ResourcePatternResolver#getResources(String)}	 增加对ant风格等的支持, 支持一次导入多个资源 , {@link ApplicationContext} 也是这个的子接口
 *  			{@link PathMatchingResourcePatternResolver}	  支持ant等风格
 *
 * @author : dzj
 * @create: 2021-10-16 19:36
 */
@Slf4j
@Configuration
@ComponentScan("com.imooc")
public class Debug0605 {

	public static void main(String[] args) {
		String xmlPath = "F:\\ideaProjectSource\\spring-framework-5.1.x\\spring-demo\\src\\main\\resources\\spring\\spring-config.xml";
	//	ApplicationContext ctx = new FileSystemXmlApplicationContext(xmlPath);
		ApplicationContext ctx = new AnnotationConfigApplicationContext(Debug0605.class);
		WelcomeController welcomeController = ctx.getBean(WelcomeController.class);
		welcomeController.handleRequest();
		for (String beanDefinitionName : ctx.getBeanDefinitionNames()) {
		//	log.info();
	//		log.info("beanDefinitionName: {}",beanDefinitionName);
		}
	}
}
